<template>
  <div>
    <el-button size="mini" type="text" @click="to">修改</el-button>
    <eForm ref="form" :sup_this="sup_this" :is-add="false"/>
  </div>
</template>
<script>
import eForm from './form'
export default {
  components: { eForm },
  props: {
    data: {
      type: Object,
      required: true
    },
    sup_this: {
      type: Object,
      required: true
    }
  },
  methods: {
    to() {
      const _this = this.$refs.form
      _this.fileList = []
      _this.faultDevices = []
      _this.pictures = []
      _this.getEquipment()
      this.data.reqiureTime = this.data.reqiureTime == null ? this.data.reqiureTime : new Date(this.data.reqiureTime)
      _this.form = {
        id: this.data.id,
        customerId: this.data.customerId,
        customerName: this.data.customerName,
        faultDevice: this.data.faultDevice,
        faultDesc: this.data.faultDesc,
        faultPicture: this.data.faultPicture,
        reqiureTime: this.data.reqiureTime,
        address: this.data.address,
        notes: this.data.notes,
        linker: this.data.linker,
        cellphone: this.data.cellphone,
        inputOperator: this.data.inputOperator,
        inputTime: this.data.inputTime,
        source: this.data.source
      }
      this.data.faultDevice.split(',').forEach(function(data, index) {
        _this.faultDevices.push(Number(data))
      })
      this.data.faultPicture.split(',').forEach(function(data, index) {
        if (data != null && data !== '') {
          _this.fileList.push({ url: 'http://localhost:8000/api/picture/' + data, id: data })
          _this.pictures.push({ id: data })
        }
      })
      _this.dialog = true
    }
  }
}
</script>

<style scoped>
  div{
    display: inline-block;
    margin-right: 3px;
  }
</style>
